public class Exercise5 {
    public int maxProfit(int[] prices) {
        int Profit = 0;
        int n = prices.length;
        for(int i = 0;i < n-1;i++) {
            if(prices[i] < prices[i+1]) {
                Profit =Profit + (prices[i+1] - prices[i]);
            }
        }
        return Profit;
    }
}
